home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_13_11 / phillip2 / cipspr.c < prev    next >
C/C++ Source or Header  |  1993-06-04  |  4KB  |  151 lines

  1.  
  2.  
  3.     /***********************************************
  4.     *
  5.     *   file d:\cips\cipspr.c
  6.     *
  7.     *   Functions: This file contains
  8.     *      main
  9.     *
  10.     *   Purpose:
  11.     *      This is the main routine of a
  12.     *      stand alone program that prints
  13.     *      TIFF images to the HP DeskJet printer
  14.     *      graphically.
  15.     *
  16.     *      You can run this program using either
  17.     *      the command line or via menus.
  18.     *
  19.     *      cipspr image-name [help -i -h -e -il -ie -t]
  20.     *
  21.     *      cipspr help - gives you a usage message
  22.     *
  23.     *      cipspr - gives you the menu interface
  24.     *
  25.     *      cipspr image-name - displays that image
  26.     *
  27.     *      Options:
  28.     *         -i  - invert the image when displaying
  29.     *         -h  - show the histogram
  30.     *         -e  - use histogram equalization
  31.     *         -il - specify initial line
  32.     *         -ie - specify initial element
  33.     *         -t  - means the words following -t
  34.     *               are a title to display below
  35.     *               the image.  Always put the -t
  36.     *               as the final option.
  37.     *
  38.     *   External Calls:
  39.     *      gin.c - get_image_name
  40.     *      rtiff.c - read_tiff_image
  41.     *      tiff.c - read_tiff_header
  42.     *      display.c - display_menu_for_display_image
  43.     *      djet.c - print_graphics_image
  44.     *
  45.     *   Modifications:
  46.     *      5 June 1993 - created
  47.     *
  48.     *************************************************/
  49.  
  50. #include "cips.h"
  51.  
  52.  
  53. short the_image[ROWS][COLS];
  54. short the_image2[ROWS][COLS];
  55.  
  56. main(argc, argv)
  57.    int argc;
  58.    char *argv[];
  59. {
  60.    char color_transform[80],
  61.         monitor_type[80],
  62.         name[80],
  63.         title[80];
  64.  
  65.    int  display_colors = 16,
  66.         i              = 0,
  67.         ie             = 1,
  68.         il             = 1,
  69.         image_colors   = 256,
  70.         invert         = 0,
  71.         j              = 0,
  72.         l              = 0,
  73.         le             = COLS+1,
  74.         ll             = ROWS+1,
  75.         show_hist      = 0;
  76.  
  77.    struct tiff_header_struct image_header;
  78.  
  79.    my_clear_text_screen();
  80.  
  81.    strcpy(name, "d:/pix/adam256.tif");
  82.    strcpy(color_transform, "Straight mode");
  83.    strcpy(monitor_type, "VGA");
  84.    strcpy(title, "");
  85.  
  86.    if(argc == 2  && (strcmp(argv[1], "help") == 0)){
  87.       printf("\nusage: cipspr image-name"
  88.              " [help -i -h -e -il -ie -t]\n");
  89.       exit(1);
  90.    }  /* ends if cipspr help */
  91.  
  92.    if(argc > 1){
  93.       strcpy(name, argv[1]);
  94.       read_tiff_header(name, &image_header);
  95.  
  96.       i=2;
  97.       while(i <= argc){
  98.          if(strcmp(argv[i], "-i") == 0)
  99.             invert = 1;
  100.          if(strcmp(argv[i], "-h") == 0)
  101.             show_hist = 1;
  102.          if(strcmp(argv[i], "-e") == 0)
  103.             strcpy(color_transform, 
  104.                    "Histogram Equalization");
  105.          if(strcmp(argv[i], "-il") == 0){
  106.             i++;
  107.             il = atoi(argv[i]);
  108.             ll = il + COLS;
  109.          }
  110.          if(strcmp(argv[i], "-ie") == 0){
  111.             i++;
  112.             ie = atoi(argv[i]);
  113.             le = ie + COLS;
  114.          }
  115.          if(strcmp(argv[i], "-t") == 0){
  116.             i++;
  117.             strcpy(title, " ");
  118.             while(i < argc){
  119.                strcat(title, argv[i]);
  120.                strcat(title, " ");
  121.                i++;
  122.             }
  123.          }
  124.          i++;
  125.       }  /* ends loop over i argc */
  126.  
  127.       print_graphics_image(the_image, the_image2,
  128.                name, il, ie, ll, le, image_colors,
  129.                invert, title, show_hist,
  130.                color_transform);
  131.  
  132.       exit(2);
  133.    }  /* ends if argc > 2 */
  134.  
  135.  
  136.    get_image_name(name);
  137.    read_tiff_header(name, &image_header);
  138.    get_parameters(&il, &ie, &ll, &le);
  139.    display_menu_for_display_image(&image_colors,
  140.                &display_colors, &invert,
  141.                color_transform, monitor_type,
  142.                &show_hist);
  143.    printf("\nEnter title>");
  144.    gets(title);
  145.    print_graphics_image(the_image, the_image2,
  146.             name, il, ie, ll, le, image_colors,
  147.             invert, title, show_hist,
  148.             color_transform);
  149.  
  150. }  /* ends main */
  151.